<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <div>1</div>
   <div>2</div>
   <div>3</div>
   <div>4</div>
   <div>5</div>
   <script>
    // 获取单个页面元素
    const div1=document.querySelector("div")
    console.log(div1)

    // 获取多个页面元素
    const divList=document.querySelectorAll('div') 
    divList.forEach(div=>{
        div.style.backgroundColor="red"
    })

   </script>
</body>